package com.cnhaimei.com;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import com.cnhaimei.vod.util.Util;

import android.os.Environment;
import android.text.format.DateUtils;

public class VODLog {
	// private File mFileObject;
	//	
	// VODLog
	private static boolean isDebug = true;

	public static void e(String tag, String s) {
		if (!isDebug) {
			return;
		}
		StringBuffer sb = new StringBuffer();
		
		sb.append(
		DateUtils.formatDateTime(Util.mApp, System.currentTimeMillis(),
				DateUtils.FORMAT_SHOW_TIME));
		sb.append(" ");
		sb.append(tag);
		sb.append(" ");
		sb.append(s + "\n");

		if (sb.length() > 0) {
			
			File mFileObject = new File(Environment
					.getExternalStorageDirectory()
					+ Util.LOG_FILE);

			if (mFileObject != null) {
//				if (!mFileObject.exists()) {
//					mFileObject.mkdir();
//				}
				FileOutputStream outputStream = null;

				try {
					outputStream = new FileOutputStream(mFileObject, true);
					outputStream.write(sb.toString().getBytes());

				} catch (FileNotFoundException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				} finally {
					if (null != outputStream) {
						try {
							outputStream.close();
						} catch (IOException e) {
							e.printStackTrace();
						}
					}
				}
			}
		}
	}
}
